import javax.media.opengl.GL;

public class BBox {

	double xMax, xMin, yMax, yMin = 0;

	public BBox(double xMax, double xMin, double yMax, double yMin) {
		super();
		this.xMax = xMax;
		this.xMin = xMin;
		this.yMax = yMax;
		this.yMin = yMin;
	}

	public double getxMax() {
		return xMax;
	}

	public void setxMax(double xMax) {
		this.xMax = xMax;
	}

	public double getxMin() {
		return xMin;
	}

	public void setxMin(double xMin) {
		this.xMin = xMin;
	}

	public double getyMax() {
		return yMax;
	}

	public void setyMax(double yMax) {
		this.yMax = yMax;
	}

	public double getyMin() {
		return yMin;
	}

	public void setyMin(double yMin) {
		this.yMin = yMin;
	}

	public void updateBBox(PointF ponto) {
		if ((ponto.getX() > xMax)) {
			xMax = ponto.getX();
		}
		if ((ponto.getX() < xMin)) {
			xMin = ponto.getX();
		}
		if ((ponto.getY() > yMax)) {
			yMax = ponto.getY();
		}
		if ((ponto.getY() < yMin)) {
			yMin = ponto.getY();
		}
	}


	public void desenhar(GL gl, boolean selected) {
		gl.glColor3f(0.0f, 0.0f, 1.0f);
		gl.glLineWidth(5);
		gl.glPointSize(5);
		if (selected) {
			gl.glEnable(GL.GL_LINE_STIPPLE);
			gl.glLineStipple(1, (short) 0x00FF);		
		}
		gl.glBegin(gl.GL_LINE_LOOP);
		
		gl.glVertex2d(xMax, yMin);
		gl.glVertex2d(xMax, yMax);
		gl.glVertex2d(xMin, yMax);
		gl.glVertex2d(xMin, yMin);
		
		gl.glEnd();
		
		
		if(selected){
			gl.glDisable(GL.GL_LINE_STIPPLE);
		}
	}

}
